<?php

namespace app\store\validate;

use think\Validate;

class GoodsCategoryValidate extends Validate
{
    protected $rule = [
        'parent_id' => 'require|integer',
        'sort' => 'require|integer',
        'name' => 'require|max:30',
        'icon' => 'max:255',
        'desc' => 'max:255',
        'is_home' => 'in:0,1',
        'status' => 'in:0,1'
    ];


    protected $message = [
        'id.require' => '非法请求',
        'id.integer' => '非法请求',
        'sort.require' => '排序不能为空',
        'parent_id.require' => '请选择父级!',
        'icon.max' => '非法图标!',
        'desc.max' => '非法描述',
        'status.in' => '无效的状态值!',
    ];


    public function sceneSwitch()
    {
        return $this->only(['id','status','is_home'])
                    ->append('id', 'require|integer');
    }

    public function sceneEdit()
    {
    	return $this->only(['id','sort','parent_id','name','icon','desc','status'])
                    ->append('id', 'require|integer');
            
    }   
}